
<?php  
require_once('../system/common.inc.php');
base_url();
$rewrite_mod = get_option('rewrite_mod');
switch($rewrite_mod){
	case 3:
		$rewrite_url = array('view' => 'view/%d', 'view_nohistory' => 'view/%d/nohistory', 'screenshot' => 'screenshot/%d', 'history' => 'history/%d', 'contact' => 'contact/%d', 'section' => 'section/%d', 'report' => 'report/%d', 'report_support' => 'report/%1$d/%2$d', 'more' => 'more/%d', 'more_offset' => 'more/%1$d/%2$d', 'misc' => 'misc');
		break;
	case 1:
	case 2:
	default:
		$rewrite_url = array('view' => 'index.php?method=view&amp;pid=%d', 'view_nohistory' => 'index.php?pid=%d&amp;addr=nohistory', 'screenshot' => 'index.php?method=screenshot&amp;pid=%d', 'history' => 'index.php?method=history&amp;pid=%d', 'contact' => 'index.php?method=contact&amp;pid=%d', 'section' => 'index.php?method=section&amp;pid=%d', 'report' => 'index.php?method=report&amp;pid=%d', 'report_support' => 'index.php?method=report&amp;pid=%1$d&amp;support=%2$d', 'more' => 'index.php?method=more&amp;pid=%d', 'more_offset' => 'index.php?method=more&amp;pid=%1$d&amp;offset=%2$d', 'misc' => 'misc.php');
		break;
}
function echo_rewrite_url($type, $variable1, $variable2=''){
	global $rewrite_url;
	echo SITE_URL;
	printf($rewrite_url[$type], $variable1, $variable2);
}
class_loader('Mobile_Detect');
$detect = new Mobile_Detect;
if(!$detect->isiOS()){
	if (DCRM_PCINDEX == 2) {
		header("Location: ".SITE_URL.$rewrite_url['misc.php']);
		exit();
	} else {
		$isCydia = false;
	}
} else {
	if (DCRM_MOBILE == 2) {
		if (!strpos($detect->getUserAgent(), 'Cydia')) {
			$isCydia = false;
		} else {
			$isCydia = true;
		}
	} else {
		exit('Access Denied');
	}
}
if (file_exists('Release')) {
	$release = file('Release');
	$release_origin = __('No Name');
	$release_mtime = filemtime('Release');
	$release_time = date('Y-m-d H:i:s',$release_mtime);
	foreach ($release as $line) {
		if(preg_match('#^Origin#', $line)) {
			$release_origin = trim(preg_replace("#^(.+):\\s*(.+)#","$2", $line));
		}
		if(preg_match("#^Description#", $line)) {
			$release_description = trim(preg_replace("#^(.+):\\s*(.+)#","$2", $line));
		}
	}
} else {
	$release_origin = __('新手帮助');
}
if (isset($_GET['pid'])) {
	if (ctype_digit($_GET['pid']) && intval($_GET['pid']) <= 10000) {
		function device_check(){
			global $detect;
			$device_type = array('iPhone', 'iPod', 'iPad');
			for ($i = 0; $i < count($device_type); $i++) {
				$check = $detect->version($device_type[$i]);
				if ($check !== false) {
					if (isset($_SERVER['HTTP_X_MACHINE'])) {
						$DEVICE = $_SERVER['HTTP_X_MACHINE'];
					} else {
						$DEVICE = 'Unknown';
					}
					$OS = str_replace('_', '.', $check);
					break;
				}
			}
			return array('DEVICE' => $DEVICE, 'OS' => $OS);
		}

		if (isset($_GET['method']) && $_GET['method'] == 'screenshot') {
			$index = 2;
			$title = __('View Screenshots');
		} elseif (isset($_GET['method']) && $_GET['method'] == 'report') {
			$device_info = device_check();
			if (!isset($_GET['support'])) {
				$index = 3;
			} else {
				if ($_GET['support'] == '1') {
					$support = 1;
				} elseif ($_GET['support'] == '2') {
					$support = 2;
				} elseif ($_GET['support'] == '3') {
					$support = 3;
				} else {
					$support = 0;
				}
				$index = 4;
			}
			$title = __('Report Problems');
		} elseif (isset($_GET['method']) && $_GET['method'] == 'history') {
			$index = 5;
			$title = __('Version History');
		} elseif (isset($_GET['method']) && $_GET['method'] == 'contact') {
			$index = 6;
			$title = __('Contact us');
		} elseif (isset($_GET['method']) && $_GET['method'] == 'section') {
			$index = 7;
			$title = __('Package Category');
		} elseif (isset($_GET['method']) && $_GET['method'] == 'more') {
			$index = 8;
			$section = DB::fetch_first("SELECT `Name`, `Icon` FROM `".DCRM_CON_PREFIX."Sections` WHERE `ID` = '".(int)$_GET['pid']."'");
			$q_name = DB::real_escape_string($section['Name']);
			if (isset($_GET['offset']) && !empty($_GET['offset']) && ctype_digit($_GET['offset'])) {
				$offset = intval($_GET['offset']);
			} else {
				$offset = 0;
			}
			$packages = DB::fetch_all("SELECT `ID`, `Name`, `Package` FROM `".DCRM_CON_PREFIX."Packages` WHERE (`Stat` = '1' AND `Section` = '".$q_name."') ORDER BY `ID` DESC LIMIT 10 OFFSET ".$offset);
			foreach($packages as $package){
				if(!empty($package)){
					if ($isCydia) { ?>
				<a href="cydia://package/<?php echo($package['Package']); ?>" target="_blank">
<?php					} else { ?>
				<a href="<?php echo_rewrite_url('view', $package['ID']);?>">
<?php					} ?>
					<img class="icon" src="<?php echo(SITE_URL); ?>icon/<?php echo(empty($section['Icon']) ? 'default/unknown.png' : $section['Icon']); ?>">
					<div>
						<div>
							<label>
								<p><?php echo($package['Name']); ?></p>
							</label>
						</div>
					</div>
				</a>
<?php
				}
			}
			exit();
		} elseif (!isset($_GET['method']) || (isset($_GET['method']) && $_GET['method'] == 'view')) {
			$index = 1;
			$title = __('View Package');
			$package_id = (int)DB::real_escape_string($_GET['pid']);
			$package_info = DB::fetch_first("SELECT `Name`, `Version`, `Author`, `Package`, `Description`, `DownloadTimes`, `Multi`, `CreateStamp`, `Size`, `Installed-Size`, `Section`, `Homepage`, `Tag`, `Level`, `Price`, `Purchase_Link`, `Changelog`, `Changelog_Older_Shows`, `Video_Preview`, `System_Support`, `ScreenShots` FROM `".DCRM_CON_PREFIX."Packages` WHERE `ID` = '".$package_id."' LIMIT 1");
			if ($package_info) $title = $title.' - '.$package_info['Name'];
		} else {
			httpinfo(405);
			exit();
		}
	} else {
		httpinfo(405);
		exit();
	}
} elseif (!isset($_GET['method'])) {
	$index = 0;
	$title = $release_origin;
} else {
	httpinfo(405);
	exit();
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title><?php echo($title); ?></title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8mb4" />
		<meta name="apple-mobile-web-app-title" content="<?php echo($release_origin); ?>" />
		<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
		<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<meta name="HandheldFriendly" content="true" />
		<meta name="format-detection" content="telephone=no" />
		<meta name="robots" content="index, follow" />
<?php
if (defined("AUTOFILL_SEO")) {
?>
		<meta name="title" content="<?php echo(AUTOFILL_SEO); ?>" />
<?php
}
if (!empty($release_description)) {
?>
		<meta name="description" content="<?php echo($release_description); ?>" />
<?php
}
if (defined("AUTOFILL_KEYWORDS")) {
?>
		<meta name ="keywords" content="<?php echo(AUTOFILL_KEYWORDS); ?>" />
<?php
}
if ($isCydia) {
?>
		<base target="_blank">
<?php
} else {
?>
		<base target="_top">
<?php
}
?>
		<link rel="apple-touch-icon" href="<?php echo(SITE_URL); ?>../CydiaIcon.png">
		<link rel="shortcut icon" href="<?php echo(SITE_URL); ?>../favicon.ico">
		<link type="text/css" media="screen" rel="stylesheet" href="./help/help.css">
	</head>
	<body class="pinstripe">
<html>
<head>
<title>新手阅读</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0"/>
<link type="text/css" media="screen" rel="stylesheet" href="../css/help.css" />

</head>
<body class="pinstripe">
<panel>

<fieldset style="font-size:15px;"> 
    <div>
        <p><strong>问：</strong>源是什么？</p>
        <hr/>
        <p>源相当于一个软件商店。</p>
    </div>
</fieldset>

<fieldset style="font-size:15px;"> 
    <div>
        <p><strong>问：</strong>为什么要添加第三方源？</p>
        <hr/>
        <p>Cydia会自带两个（bigboss、modmyi）软件下载源（saurik源多数为依赖、命令。ZodTTD主题铃声），这些软件源东西很多，但是好玩实用的都需要花钱，第三方源，多数为做正版破解分享，如果您不想花钱又想玩实用软件（或者不确定是不是你想要的软件该不该购买，想试用），您需要添加 <strong><?php echo(AUTOFILL_SEO); ?></strong></p>
    </div>
</fieldset>

<fieldset style="font-size:15px;"> 
    <div>
        <p><strong>问：</strong>怎样添加源？</p>
        <hr/>
        <p>打开“<strong>Cydia</strong>”，点击下方<strong>“软件源”</strong>，看到软件源列表后点击右上角“<strong>编辑</strong>”，然后点击左上角“<strong>添加</strong>”，在弹出的窗中输入您要添加的软件源，点击“<strong>添加源</strong>”即可</p>
    </div>

</fieldset>

<fieldset style="font-size:15px;"> 
    <div>
        <p><strong>问：</strong>怎样下载软件。</p>
            <hr/>
        <p>您可以点击Cydia底部的“<strong>软件源</strong>”中查看软件分类，点击要安装软件的分类，找到软件，点击，稍等一会（加载软件的功能描述），然后点击右上角的“<strong>安装</strong>”即可（注意，自带源某些可能需要付费）</p>
    </div>
        
</fieldset>

<fieldset style="font-size:15px;"> 
    <div>
        <p><strong>问：</strong>怎样卸载已安装的软件。</p>
        <hr/>
        <p>打开Cydia点击底部“<strong>已安装</strong>”，再点击右上方“<strong>最近</strong>”，找到您安装的软件，或者点击“<strong>搜索</strong>”搜索到您安装的软件，点击进入，点击右上角的“更改”或者“卸载”。
        <hr/>
        <p><strong>注意</strong>：请不要删除不是系统自带软件包</p>
    </div>
        
</fieldset>

<fieldset style="font-size:15px;"> 
    <div>
        <p><strong>问：</strong>cydia安装完软件需要重启吗？。</p>
        <hr/>
        <p>一般的插件、工具都无需重启手机，在安装完一个插件后cydia安装页底部会有提示（返回，注销，重启），请按具体要求点击即可。</p>
    </div>
</fieldset>

<fieldset style="font-size:15px;"> 
    <div>
        <p><strong>问：</strong>什么是刷新源？</p>
        <hr/>
        <p>刷新源就是更新您每个源的内容，重新从每个源服务器获取最新的文件，这样您才可以看到最新更新的软件。</p>
    </div>
</fieldset>

<fieldset style="font-size:15px;"> 
    <div>
        <p><strong>问：</strong>怎样刷新源？</p>
        <hr/>
        <p>每次进入Cydia都会自动刷新（您会看到Cydia顶部出现一个不停显示字的黑色条），您可以等待它消失，这时候就刷新完了。
        <br/>
        <p>您也可以选择手动刷新：点击底部“<strong>变更</strong>”，会看到左上角的“<strong>刷新</strong>”按钮，点击等待黑色条消失即可</p>
    </div>
</fieldset>

<fieldset style="font-size:15px;"> 
    <div><p><strong>问：</strong>是否能使用4G、3G、edge刷新源？</p>
    <hr/><p>使用4G 3G可以，不推荐您使用EDGE网络（即：系统左上角运营商logo右侧显示一个“o”或者“E”的时候）</p>
    </div>
</fieldset>

<fieldset style="font-size:15px;"> 
    <div>
        <p><strong>问：</strong>为什么刷新源后出现一些黄色、红色英文？</p>
        <hr/>
        <p>如果出现如GPG error...，Failed to fetch..，等错误，请检查您的网络</p>
    </div>
</fieldset>

            <footer id="footer" >
                <p>
                    <span class="source-name"><a href="<?php echo(SITE_URL); ?>" style="color: #6d6d72;"><?php echo(AUTOFILL_SEO); ?></a></span> ·
                    <span id="section">新手帮助</span>
                </p>
            </footer>
</panel>
        
</body>
</html>